home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / cxl52_1.zip / CXLKEY.H < prev    next >
C/C++ Source or Header  |  1990-02-17  |  4KB  |  105 lines

  1. /*
  2.    ┌──────────────────────────────────────────────────────────────────────────┐
  3.    │                                                                          │
  4.    │  CXLKEY.H  -  CXL is Copyright (c) 1987-1990 by Mike Smedley.            │
  5.    │                                                                          │
  6.    │  This header file contains function prototypes and definitions for       │
  7.    │  keyboard functions.  Keyboard functions for windowing functions are     │
  8.    │  defined in CXLWIN.H                                                     │
  9.    │                                                                          │
  10.    └──────────────────────────────────────────────────────────────────────────┘
  11. */
  12.  
  13. #if defined(__TURBOC__)                         /* Turbo C */
  14.     #if __STDC__
  15.         #define _Cdecl
  16.     #else
  17.         #define _Cdecl  cdecl
  18.     #endif
  19.     #define _Near
  20. #elif defined(__ZTC__)                          /* Zortech C++ */
  21.     #define _Cdecl
  22.     #define _Near
  23. #elif defined(M_I86) && !defined(__ZTC__)       /* Microsoft C/QuickC */
  24.     #if !defined(NO_EXT_KEYS)
  25.         #define _Cdecl  cdecl
  26.         #define _Near   near
  27.     #else
  28.         #define _Cdecl
  29.         #define _Near
  30.     #endif
  31. #endif
  32.  
  33. /*---------------------------[ function prototypes ]-------------------------*/
  34.  
  35. void     _Cdecl capsoff(void);
  36. void     _Cdecl capson(void);
  37. struct _onkey_t *_Cdecl chgonkey(struct _onkey_t *kblist);
  38. void     _Cdecl freonkey(void);
  39. int      _Cdecl getchf(char *valid,int defchar);
  40. int      _Cdecl getns(char *str,int maxchars);
  41. unsigned _Cdecl getxch(void);
  42. int      _Cdecl inputsf(char *str,char *fmt);
  43. void     _Cdecl kbclear(void);
  44. int      _Cdecl kbmhit(void);
  45. int      _Cdecl kbput(unsigned xch);
  46. int      _Cdecl kbputs(char *str);
  47. unsigned _Cdecl kbstat(void);
  48. void     _Cdecl numoff(void);
  49. void     _Cdecl numon(void);
  50. int      _Cdecl scancode(int ch);
  51. int      _Cdecl setonkey(unsigned keycode,void (_Cdecl *func) (void),
  52.                          unsigned pass);
  53. int      _Cdecl waitkey(void);
  54. int      _Cdecl waitkeyt(int duration);
  55.  
  56. /*------------------------[ definition of kbuf record ]----------------------*/
  57.  
  58. struct _kbuf_t {
  59.     struct _kbuf_t *prev;       /* previous record */
  60.     struct _kbuf_t *next;       /* next record     */
  61.     unsigned xch;               /* keypress        */
  62. };
  63.  
  64. /*-----------------------[ definition of onkey record ]----------------------*/
  65.  
  66. struct _onkey_t {
  67.     struct _onkey_t *prev;      /* pointer to previous record      */
  68.     struct _onkey_t *next;      /* pointer to next record          */
  69.     unsigned int keycode;       /* Scan/ASCII code of trap key     */
  70.     void (*func) (void);        /* address of onkey function       */
  71.     unsigned int pass;          /* key to pass back, 0=don't pass  */
  72. };
  73.  
  74. /*-------------------[ definition of keyboard info record ]------------------*/
  75.  
  76. struct _kbinfo_t {
  77.     struct _kbuf_t *kbuf;       /* pointer to head record in key buffer      */
  78.     struct _onkey_t *onkey;     /* pointer to head record in onkey list      */
  79.     void (*kbloop) (void);      /* pointer to function to call while waiting */
  80.     unsigned char inmenu;       /* inmenu flag used by menuing functions     */
  81.     unsigned char source;       /* source of keypress 0=kb, 1=kbuf, 2=mouse  */
  82. };
  83.  
  84. extern struct _kbinfo_t _Near _Cdecl _kbinfo;
  85.  
  86. /*-------------[ keyboard status codes returned from kbstat() ]--------------*/
  87.  
  88. #define RSHIFT      1       /* right shift pressed   */
  89. #define LSHIFT      2       /* left shift pressed    */
  90. #define CTRL        4       /* [Ctrl] pressed        */
  91. #define ALT         8       /* [Alt] pressed         */
  92. #define SCRLOCK     16      /* [Scroll Lock] toggled */
  93. #define NUMLOCK     32      /* [Num Lock] toggled    */
  94. #define CAPSLOCK    64      /* [Caps Lock] toggled   */
  95. #define INS         128     /* [Ins] toggled         */
  96.  
  97. /*-----------------------[ macro-function definitions ]-----------------------*/
  98.  
  99. #if !defined(MK_FP)
  100. #define MK_FP(seg,ofs)      ((void far *) (((unsigned long)(seg) << 16) | \
  101.                             (unsigned)(ofs)))
  102. #endif
  103. #define clearkeys()         while(kbhit()) getch()
  104. #define setkbloop(a)        (_kbinfo.kbloop=a)
  105.